package cn.itcast.shop.categorysecond;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import cn.itcast.shop.category.Category;
import cn.itcast.shop.utils.PageHibernateCallback;



public class CategorySecondDao extends HibernateDaoSupport{

	public Integer findCount() {
		List<Long> list=this.getHibernateTemplate().find("select count(*) from CategorySecond");
		if(list.size()>0){
			return list.get(0).intValue();
		}
		return null;
	}

	public List<CategorySecond> findByPage(Integer begin, Integer limit) {
		String hql="from CategorySecond";
		List<CategorySecond> list=this.getHibernateTemplate().executeFind(new PageHibernateCallback<CategorySecond>(hql, null, begin, limit));
		if(list.size()>0){
			return list;
		}
		return null;
	}

	public void save(CategorySecond categorySecond) {
		// TODO Auto-generated method stub
		this.getHibernateTemplate().save(categorySecond);
	}

	public void delete(CategorySecond categorySecond) {
		categorySecond=this.getHibernateTemplate().get(CategorySecond.class, categorySecond.getCsid());
		this.getHibernateTemplate().delete(categorySecond);
		
	}

	public CategorySecond findByCsid(Integer csid) {
		// TODO Auto-generated method stub
		return this.getHibernateTemplate().get(CategorySecond.class, csid);
	}

	public void update(CategorySecond categorySecond) {
		this.getHibernateTemplate().update(categorySecond);
		
	}

	public List<CategorySecond> findAll() {
		// TODO Auto-generated method stub
		return this.getHibernateTemplate().find("from CategorySecond");
	}

}
